package com.example.piedrapapeltijeralagartospok;

import controlador.Controlador;
import controlador.Listener_P1;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class P1_Activity extends Activity {
	private Controlador c=new Controlador(this);
	Listener_P1 l = new Listener_P1(this);

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_p1_);

		ImageView b_piedra = (ImageView) findViewById(R.id.piedra);
		b_piedra.setOnClickListener(l);

		ImageView b_papel = (ImageView) findViewById(R.id.papel);
		b_papel.setOnClickListener(l);

		ImageView b_tijera = (ImageView) findViewById(R.id.tijera);
		b_tijera.setOnClickListener(l);

		ImageView b_lagarto = (ImageView) findViewById(R.id.lagarto);
		b_lagarto.setOnClickListener(l);

		ImageView b_spok = (ImageView) findViewById(R.id.spok);
		b_spok.setOnClickListener(l);
		
		TextView turno_nombre =(TextView) findViewById(R.id.nombre_turno);
		
		Bundle a = this.getIntent().getExtras();
		turno_nombre.setText("Turno de "+a.getString("nombre"));
		

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public ImageView getPiedra() {
		ImageView iv = (ImageView) findViewById(R.id.piedra);
		return iv;
	}
	
	public ImageView getPapel() {
		ImageView iv = (ImageView) findViewById(R.id.papel);
		return iv;
	}

	public ImageView getTijera() {
		ImageView iv = (ImageView) findViewById(R.id.tijera);
		return iv;
	}

	public ImageView getLagarto() {
		ImageView iv = (ImageView) findViewById(R.id.lagarto);
		return iv;
	}
	public ImageView getSpok() {
		ImageView iv = (ImageView) findViewById(R.id.spok);
		return iv;
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	    
	  if (keyCode == KeyEvent.KEYCODE_BACK) {
    
		  	Toast.makeText(this, "No hagas trampas", Toast.LENGTH_LONG).show();
  }else{
	//para las demas cosas, se reenvia el evento al listener habitual
	  return super.onKeyDown(keyCode, event);
	}
	return false; }
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		if (!c.onOptionsItemSelected(item)) {

			super.onOptionsItemSelected(item);

		}
		return true;
	}
}
